x86/shadow: slightly consolidate sh_unshadow_for_p2m_change() (part II)
authorJan Beulich <jbeulich@suse.com>
Thu, 18 Aug 2022 07:28:38 +0000 (09:28 +0200)
committerJan Beulich <jbeulich@suse.com>
Thu, 18 Aug 2022 07:28:38 +0000 (09:28 +0200)
commit241702e064604dbb3e0d9b731aa8f45be448243b
tree89163c0037e64cf85029b06b9592e69f7d10e38a
parent0caf699e69d79f54b94191e2f84956713c4be0da
x86/shadow: slightly consolidate sh_unshadow_for_p2m_change() (part II)

Pull common checks out of the switch(). This includes extending a
_PAGE_PRESENT check to L1 as well, which presumably was deemed redundant
with p2m_is_valid() || p2m_is_grant(), but I think we are better off
being explicit in all cases. Note that for L2 (or higher) the grant
check isn't strictly necessary, as grants are only ever single pages.
Leave a respective assertion.

With _PAGE_PRESENT checked uniformly, the suspicious mfn_valid(omfn)
checks can be dropped rather than moved/folded - if anything we'd need
to compare against INVALID_MFN, but that won't come out of l1e_get_mfn().

For L1 replace the moved out condition with a PTE comparison: There's
no need for any update or flushing when the two match.

Signed-off-by: Jan Beulich <jbeulich@suse.com>
Acked-by: Tim Deegan <tim@xen.org>
xen/arch/x86/mm/shadow/hvm.c